package tehMod;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.Random;
import java.util.Set;

import tehUtils.BlockFinder;
import tehUtils.BlockInstance;

import net.minecraft.src.*;

public class BlockBanner extends BlockContainer {

	public static final String displayName = "Banner";
	public static final String blockName = "Banner";
	
	public static final float blockHardness = 0.50f; //2.5f;
	public static final StepSound stepSound = Block.soundWoodFootstep;
	
	public BlockBanner(int blockID) {
		super(blockID, Block.planks.blockIndexInTexture, Material.air);
		
		setBlockName(blockName);
		setHardness(blockHardness);
		setStepSound(stepSound);
		setRequiresSelfNotify();
		float f = 0.25F;
        float f1 = 1.0F;
        setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, f1, 0.5F + f);
		
		ModLoader.RegisterBlock(this);
		ModLoader.RegisterTileEntity(TileEntityBanner.class, "BannerEntity", new TileEntityBannerRenderer(ModLoader.getMinecraftInstance().theWorld));
		ModLoader.AddName(this, displayName);
	}
	
	public void onNeighborBlockChange(World world, int i, int j, int k, int l) {
		if (!world.getBlockMaterial(i, j - 1, k).isSolid()) {
            world.setBlockWithNotify(i, j, k, 0);
		}
	}
	
	public TileEntityBanner getBlockEntity() {
		return new TileEntityBanner();
	}
	
	@Override
	public void onBlockRemoval(World world, int i, int j, int k) {
		super.onBlockRemoval(world, i, j, k);
		EntityItem banner = new EntityItem(world, i, j, k, new ItemStack(mod_TehMod.bannerItem, 1));
		world.spawnEntityInWorld(banner);
	}
	
	public int quantityDropped(int i, int j, Random random) {
		return 0;
	}
	
	public int quantityDropped(Random random) {
		return 0;
	}
	
	public boolean isOpaqueCube() {
		return false;
	}
	
	public boolean renderAsNormalBlock() {
		return false;
	}
	
	public int getRenderType() {
		return -1;
	}
	
	@Override
	public boolean canPlaceBlockAt(World world, int i, int j, int k) {
		return (world.getBlockId(i, j, k) == 0 && world.getBlockId(i, j + 1, k) == 0 && world.getBlockMaterial(i, j - 1, k).isSolid());
	}
	
	public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int i, int j, int k) {
		return null;
	}

	public AxisAlignedBB getSelectedBoundingBoxFromPool(World world, int i, int j, int k) {
		setBlockBoundsBasedOnState(world, i, j, k);
		return super.getSelectedBoundingBoxFromPool(world, i, j, k);
	}

	public void setBlockBoundsBasedOnState(IBlockAccess iblockaccess, int i, int j, int k) {
		return;
	}

}
